<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>H+ 后台主题UI框架 - 空白页</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

     <link rel="shortcut icon" href="favicon.ico">  <link href="__STATIC__/layout/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__STATIC__/layout/css/font-awesome.css?v=4.4.0" rel="stylesheet">
     <link href="__STATIC__/layout/css/plugins/summernote/summernote.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/summernote/summernote-bs3.css" rel="stylesheet">
     <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/plugins/webuploader/webuploader.css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/demo/webuploader-demo.css">
    <!-- jqgrid-->
    <link href="__STATIC__/layout/css/animate.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
</head>

<body style="color:#333;padding:3px;">
    <!-- 标题 -->
    <div class="page-heade clearfix">
      <h2 class="clearfix text-center"><a class="col-md-6 title_color H_right" id="ApIn1" style="color:#333;font-size: 16px" href="apinapply1.html">AP费用需补发票列表</a> <a class="col-md-6 title_color  H_active" id="ApIn2" style=" font-size: 16px" >AP费用补发票申请</a></h2>
    </div>
    <!-- 标题 -->
     <table class="table table-bordered">
        <tr>
            <td><a href="{:url('addapinvoiceapply')}" class="btn btn-info" style="color:#fff ">新增AP补发票申请</a></td>
        </tr>
        <tr>
            <td>  <p>如需修改面单中、"补发票金额"等详细内容，请先点击"修改"，确认无误后再点"提交工作流"</p></td>
        </tr>
     </table>
     <div class="row-margin-top">
    <form action="" class="form-inline" id="form_check" method="post">
      <table class="row-margin-top tab-content table-bordered table text-center" border="1">
          <tr>
            <td><label for="" class="form-label">编号：</label><input type="text" class="form-control" name="no" value="{$data.no}"></td>
            <td><label for="">供应商：</label><input type="text" class="form-control" name="gys" value="{$data.gys}"></td>
            <td><label for="">状态：</label><select name="state" id="" class="form-control">
                    <option value="0">请选择</option>
                    {volist name="states" id="se"}
                        {if $data.state==$se.id}
                        <option value="{$se.id}" selected="selected">{$se.title}</option>
                        {else/}
                        <option value="{$se.id}">{$se.title}</option>
                        {/if}
                    {/volist}
            </select></td>
            <td>
            <div class="form-group" >
                申请时间
            </div>
             <div class="form-group">
            <input type="text" id="start" placeholder="开始日期" class="form-control layer-date " style="height: 22px;display: inline-block;" name="start" value="{$data.start}">
           </div>
            <div class="form-group">
                至
            </div>
           <div class="form-group">
            <input type="text" class="form-control layer-date"  placeholder="结束日期" style="height: 22px;display: inline-block;" id="end" name="end" value="{$data.end}">
           </div>
            </td>
            <td>
         <button class="btn btn-info query" type="button" id="check">查询</button>
           <button class="btn btn-info emptyIf" type="button" id="clear_check">清空查询条件</button>
            </td>
          </tr>
      </table>
    
      <table class="table table-striped row-margin-top table-bordered text-center bud_hei">
          <tr class="info text-center">
            <th class="text-center">NO.</th>
            <th class="text-center">编号</th>
            <th class="text-center" style="min-width: 200px;width: 200px">主题</th>
            <th class="text-center">状态</th>
            <th class="text-center">申请人</th>
            <th class="text-center">申请时间</th>
            <th class="text-center">操作</th>
          </tr>
          {volist name="apply" id="vo"}
            <tr>
                <td>{$i}</td>
                <td>
                     <a class="applying num2 ObjectNum" title="补票申请{$vo.no}" href="{:url('xiangqing')}?fpid={$vo.id}">{$vo.no}</a>
                </td>
                <td>补发票申请:{$vo.gys_name}</td>
                <td>{$vo.states}</td>
                <td>{$vo.em_name}</td>
                <td>{$vo.ctime}</td>
                <td>
                    {if $vo.state==1}
                    <a onclick="tijiao({$vo.id})">提交工作流</a> <a onclick="xiugai({$vo.id})">修改</a>  <a onclick="shanchu({$vo.id})">删除</a>
                    {else/}
                         {if $vo.state==2}
                            <a onclick="xiugai({$vo.id})">修改/作废</a>
                        {/if}
                            <a href="{:url('Workflowdb/workflowchart',['id'=>$vo.myId])}" class="J_menuItem" title="查看流程图">查看流程图</a>
                    {/if}
                   

                </td>
            </tr>
          {/volist}
      </table>
       <h5 class="text-center">
            总共有{$sum}条记录，第{$page}/{$maxpage}页，当前页：<input id="page" type="text" style="width: 70px;" value="{$page}" class="form-control" /><span id="gopage">GO</span>&nbsp;&nbsp;<span id="fistpage">首页</span>&nbsp;&nbsp; 每页显示
           <select id="pagesize">
                        <option value='10' {if condition="$list eq 10"}selected{/if}>10条</option>
                        <option value='15'{if condition="$list eq 15"}selected{/if}>15条</option>
                        <option value='20'{if condition="$list eq 20"}selected{/if}>20条</option>

            </select>
        </h5>
</form>
    </div>
  <!-- 全局js -->
    <script src="__STATIC__/layout/js/jquery.min.js?v=2.1.4"></script>
    <script src="__STATIC__/layout/js/bootstrap.min.js?v=3.3.6"></script>
    <!-- <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> -->
    <script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
      <script src="__STATIC__/layout/js/plugins/layer/laydate/laydate.js"></script>
              <script src="__STATIC__/layout/js/plugins/layer/layer.min.js"></script>
                 <script src="__STATIC__/layout/js/common.js"></script>
                  <script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>
                   <script src="__STATIC__/layout/js/contabs_sub.js"></script>
    <script>
         //翻页
        $("#pagesize").change(function(){
            $("#page-go").val(1);
            $("#list-go").val($(this).val());
            document.getElementById("form_check").submit();
        })
        $("#gopage").click(function(){
             $("#page-go").val($("#page").val());
              document.getElementById("form_check").submit();
        })
        $("#page").keyup(function(){

            if(isNaN(parseInt($(this).val()))){
                $(this).val(1);
            }else{
                $(this).val(parseInt($(this).val()));
            }
            
        })
        $("#fistpage").click(function(){
              $("#page-go").val(1);
              document.getElementById("form_check").submit();
        })
        $("#check").click(function(){
              $("#page-go").val(1);
              document.getElementById("form_check").submit();
        })
        $("#clear_check").click(function(){
            $("input[type='text']").val("");
            $("select").val(0);
            $("#page-go").val(1);
             document.getElementById("form_check").submit();
        })
    function shenhe(id){
        $.post("{:url('shenhe')}",{id:id},function(re){
                     var data=JSON.parse(re);
            if(data["state"]==1){
                swal({
                            title: "完成",
                           text: "成功审核申请",
                           type: "success"

                },function(){
                  document.getElementById("form_check").submit();
                })
            }else{
                  swal({
                          title: "错误",
                           text: data["msg"],
                           type: "warning"
                        });
                }
        })
    }
    
    function shanchu(id){
        if(confirm("您真的要删除这个申请么？")){
              $.post("{:url('shanchuap')}",{id:id},function(re){
                  // alert(re);
            var data=JSON.parse(re);
            if(data["state"]==1){
                alert("操作已成功");
                document.getElementById("form_check").submit();

               
            }else{
                  swal({
                          title: "错误",
                           text: data["msg"],
                           type: "warning"
                        });
                }
            })
        }
       
    }
    //提交工作流
function tijiao(id){
    swal({
      title: "您确定嘛?",
      text: "提交后将不能撤销，请核对完相关内容",
      type: "warning",
      showCancelButton: true,
      confirmButtonColor: "#DD6B55",
      confirmButtonText: "确定",
      cancelButtonText: "取消",
      closeOnConfirm: false
    },
    function(){
      $.post("{:url('tijiao')}",{id:id},function(re){
        //alert(re);
        var data=JSON.parse(re);
            if(data["state"]==1){

                        swal({
                                title: "完成",
                                text: "操作已成功",
                                type: "success"
                                },function(){
                                   document.getElementById("form_check").submit();
                                  //
                                });
               
                
            }else{
                 swal({
                                title: "错误",
                                text: data["msg"],
                                type: "warning"
                                });
            }
      })
    });
}
    function xiugai(id){
        location.href="{:url('xiugai')}?fpid="+id;
    }
        //日期范围限制
        var start = {
            elem: '#start',
            format: 'YYYY-MM-DD',
            
            max: '2099-06-16 23:59:59', //最大日期
            istime: true,
            istoday: false,
            choose: function (datas) {
                end.min = datas; //开始日选好后，重置结束日的最小日期
                end.start = datas //将结束日的初始值设定为开始日
            }
        };
        var end = {
            elem: '#end',
            format: 'YYYY-MM-DD',
           
            max: '2099-06-16 23:59:59',
            istime: true,
            istoday: false,
            choose: function (datas) {
                start.max = datas; //结束日选好后，重置开始日的最大日期
            }
        };
        laydate(start);
        laydate(end);
    </script>
    <script>
   $(".applying").click(menuItem); 
    function menuItem() {
    // 获取标识数据
    var dataUrl = $(this).attr('href'),
        dataIndex = $(this).data('index'),
        menuName = $.trim($(this).attr("title")),
        flag = true;
    if (dataUrl == undefined || $.trim(dataUrl).length == 0)return false;

    // 选项卡菜单已存在
    top.$('.J_menuTab').each(function () {
        if ($(this).data('id') == dataUrl) {
            if (!$(this).hasClass('active')) {
                $(this).addClass('active').siblings('.J_menuTab').removeClass('active');
                scrollToTab(this);
                // 显示tab对应的内容区
                top.$('.J_mainContent .J_iframe').each(function () {
                    if (top.$(this).data('id') == dataUrl) {
                        top.$(this).show().siblings('.J_iframe').hide();
                        return false;
                    }
                });
            }
            flag = false;
            return false;
        }
    });

    // 选项卡菜单不存在
    if (flag) {
        var str = '<a href="javascript:;" class="active J_menuTab" data-id="' + dataUrl + '">' + menuName + ' <i class="fa fa-times-circle"></i></a>';
        top.$('.J_menuTab').removeClass('active');

        // 添加选项卡对应的iframe
        var str1 = '<iframe class="J_iframe" name="iframe' + dataIndex + '" width="100%" height="100%" src="' + dataUrl + '" frameborder="0" data-id="' + dataUrl + '" seamless></iframe>';
        top.$('.J_mainContent').find('iframe.J_iframe').hide().parents('.J_mainContent').append(str1);

        //显示loading提示
//            var loading = layer.load();
//
//            $('.J_mainContent iframe:visible').load(function () {
//                //iframe加载完成后隐藏loading提示
//                layer.close(loading);
//            });
        // 添加选项卡
        top.$('.J_menuTabs .page-tabs-content').append(str);
        scrollToTab(top.$('.J_menuTab.active'));
    }
    return false;
}
//滚动到指定选项卡
function scrollToTab(element) {
    var marginLeftVal = calSumWidth(top.$(element).prevAll()), marginRightVal = calSumWidth(top.$(element).nextAll());
    // 可视区域非tab宽度
    var tabOuterWidth = calSumWidth(top.$(".content-tabs").children().not(".J_menuTabs"));
    //可视区域tab宽度
    var visibleWidth = top.$(".content-tabs").outerWidth(true) - tabOuterWidth;
    //实际滚动宽度
    var scrollVal = 0;
    if (top.$(".page-tabs-content").outerWidth() < visibleWidth) {
        scrollVal = 0;
    } else if (marginRightVal <= (visibleWidth - top.$(element).outerWidth(true) - top.$(element).next().outerWidth(true))) {
        if ((visibleWidth - top.$(element).next().outerWidth(true)) > marginRightVal) {
            scrollVal = marginLeftVal;
            var tabElement = element;
            while ((scrollVal - top.$(tabElement).outerWidth()) > (top.$(".page-tabs-content").outerWidth() - visibleWidth)) {
                scrollVal -= top.$(tabElement).prev().outerWidth();
                tabElement = top.$(tabElement).prev();
            }
        }
    } else if (marginLeftVal > (visibleWidth - top.$(element).outerWidth(true) - top.$(element).prev().outerWidth(true))) {
        scrollVal = marginLeftVal - top.$(element).prev().outerWidth(true);
    }
    top.$('.page-tabs-content').animate({
        marginLeft: 0 - scrollVal + 'px'
    }, "fast");
}
//计算元素集合的总宽度
function calSumWidth(elements) {
    var width = 0;
    top.$(elements).each(function () {
        width += top.$(this).outerWidth(true);
    });
    return width;
}

    $('.approved').on('click',menuItem);

    </script>
</body>

</html>
